package cn.com.kh;

import cn.com.elite.PropertiesUtil;
import cn.com.elite.SendBatchMail;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.*;

/**
 * @projectName: ngsapitask-ms
 * @package: cn.com.kh
 * @className: Dev
 * @author: LiJT
 * @description: TODO
 * @date: 2022-08-08 13:02
 * @version: 1.0
 */
public class SendBatchMailTest {
    private static final Log log = LogFactory.getLog(SendBatchMailTest.class);

    public static void main(String[] args) throws Exception {

        PropertiesUtil properties = new PropertiesUtil();
        boolean debugBool = Boolean.parseBoolean(properties.readValue("SendBatchMail.setDebug"));
        System.out.println("debugBool:" + debugBool);


        // 获取需要发送的邮箱
        String Cc_Mail = "405265532@qq.com,lijuntao0324@live.cn";

        // 定义发送批量邮件参数
        List<Map<String, Object>> sendList = new ArrayList<Map<String, Object>>();
        Map<String, Object> receviceMap = new HashMap<String, Object>();

        for (int i = 0; i < 3; i++) {
            // 将要发送的邮件信息插入Map
            receviceMap = new HashMap<String, Object>();
            receviceMap.put("rec_guid", i);
            receviceMap.put("documentout_guid", UUID.randomUUID());
            receviceMap.put("receviceAddress", Cc_Mail);
            receviceMap.put("subject", "工作日报清单");
            receviceMap.put("content", "邮件内容:测试");
            receviceMap.put("emlFilePath", getProperty.get("Mail.emlFilePath") + "/MailEML-" + UUID.randomUUID() + ".eml");
            receviceMap.put("attachmentList", null);

            receviceMap.put("batch_id", "123123");
            receviceMap.put("contenttype", "html");
            receviceMap.put("relativepath", "relativepath");
            receviceMap.put("trialcount", 1);
            receviceMap.put("pipe", 1);
            receviceMap.put("trialcountlimit", 5);
            receviceMap.put("sendResult", false);
            receviceMap.put("attachResult", false);

            // 将这封待发送任务Map插入List
            sendList.add(receviceMap);

        }


        List sendReList = new ArrayList();
        sendReList = SendBatchMail.goSendMail("smtp.elitecrm.com", 25, "taoli@elitecrm.com", "taoli@elitecrm.com", "Iuo916412", sendList);

    }

}
